package com.loans.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.loans.product.domain.TbTime;
import com.loans.product.service.ITbTimeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 放款时间Controller
 * 
 * @author ruoyi
 * @date 2022-12-12
 */
@RestController
@RequestMapping("/time")
public class TbTimeController extends BaseController
{
    @Autowired
    private ITbTimeService tbTimeService;

    /**
     * 查询放款时间列表
     */
    @RequiresPermissions("product:time:list")
    @GetMapping("/list")
    public TableDataInfo list(TbTime tbTime)
    {
        startPage();
        List<TbTime> list = tbTimeService.selectTbTimeList(tbTime);
        return getDataTable(list);
    }

    /**
     * 导出放款时间列表
     */
    @RequiresPermissions("product:time:export")
    @Log(title = "放款时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTime tbTime)
    {
        List<TbTime> list = tbTimeService.selectTbTimeList(tbTime);
        ExcelUtil<TbTime> util = new ExcelUtil<TbTime>(TbTime.class);
        util.exportExcel(response, list, "放款时间数据");
    }

    /**
     * 获取放款时间详细信息
     */
    @RequiresPermissions("product:time:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbTimeService.selectTbTimeById(id));
    }

    /**
     * 新增放款时间
     */
    @RequiresPermissions("product:time:add")
    @Log(title = "放款时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbTime tbTime)
    {
        return toAjax(tbTimeService.insertTbTime(tbTime));
    }

    /**
     * 修改放款时间
     */
    @RequiresPermissions("product:time:edit")
    @Log(title = "放款时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbTime tbTime)
    {
        return toAjax(tbTimeService.updateTbTime(tbTime));
    }

    /**
     * 删除放款时间
     */
    @RequiresPermissions("product:time:remove")
    @Log(title = "放款时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbTimeService.deleteTbTimeByIds(ids));
    }
}
